// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })

exports.main = async (event, context) => {
  const db = cloud.database()
  try {
    const threeBase = await db.collection('Venues')
      .where({ type: 'threeBase' })
      .field({
        _id: true,
        name: true,
        pic: true,
        picName: true,
        data: true,
        type:true
      })
      .get()
    
    const nNode = await db.collection('Venues')
    .where({ type: 'nNode' })
    .field({
      _id: true,
      name: true,
      pic: true,
      picName: true,
      data: true,
      type:true
    })
    .get()

    return {
      code: 200,
      threeBase: threeBase.data,
      nNode:nNode.data,
      message: 'success'
    }
  } catch (err) {
    return {
      code: 500,
      data: null,
      message: err.errMsg
    }
  }
}